<?php
session_start();
$loginId=$_SESSION['loginid'];
$name=$_SESSION['name'];
$userType=$_SESSION['user_type'];
$typeScheme=$_SESSION['type_scheme'];

include("config.php");
include("connection/connection.php");
$psp_id=$_REQUEST['var'];
$reference_id=$_REQUEST['referenceId'];
$qrSource="select * from tbl_dtls_q1_psp where id='$psp_id'";
		$resSource=mysql_query($qrSource);
		//echo mysql_affected_rows();
		$rowSource=mysql_fetch_assoc($resSource);
		$frm=$rowSource['loc_id'];
		
if(isset($_REQUEST['submit']))
 {
  	mysql_query("UPDATE tbl_dtls_q1_psp SET psp_taps='$_REQUEST[taps]', psp_loc='$_REQUEST[location]',psp_lat = '$_REQUEST[latitude]', psp_long = '$_REQUEST[latitude]', attached_glr='$_REQUEST[att_glr]' , attached_cwt = '$_REQUEST[att_cwt]' , sc_st = '$_REQUEST[scst]' WHERE id = '$_REQUEST[psp_id]'");
 // print_r($_REQUEST); 
  
		////////////////////////code for maintaining user history///////////////////
	
	if($typeScheme=="P&T" || $typeScheme=="TSS(P&T)")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$_POST[frmId]','21','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Piped")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$_POST[frmId]','47','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Sanitary Diggs")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$_POST[frmId]','73','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	
	
	mysql_query($qryHistory);
	///////////////////////////////

  header("Location: q1.php");
  }
		
?>
<script type="text/javascript" src="js/jquery.js"></script>
 <div class="section_format">
  <form action="psp_edit.php" method="post" name="sec5" id="sec5" >
  <input type="hidden" id="psp_id" name="psp_id" value="<?php echo $psp_id; ?>">
  <input type="hidden" name="frmId" value="<?php echo $frm;?>" />
	  <input type="hidden" name="loginId" id="loginId" value="<?php echo $loginId;?>" />
	  <input type="hidden" name="name" id="name" value="<?php echo $name;?>" />
	  <input type="hidden" name="userType" id="userType" value="<?php echo $userType;?>" />
	  <input type="hidden" name="typeScheme" id="typeScheme" value="<?php echo $typeScheme;?>" />
    <div style="height:30px" align="center"><?php echo $reference_id;?></div>
   <table border="1">
    <tr>
      <td colspan="2">&nbsp;<b>Public Stand Post (PSP)</b>&nbsp;</td>
      </tr>
   
	  
	  <tr>
      <td width="138">&nbsp;<b>Taps/PSP Nos.</b></td>
      <td width="144">&nbsp;
	<input type="text" name="taps" id="taps" value="<?php echo $rowSource['psp_taps']; ?>" onblur="int(this);" />
		</td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Location</b></td>
      <td>&nbsp;
		<input type="text" name="location" id="location" value="<?php echo $rowSource['psp_loc']; ?>" />
		</td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Latitude</b></td>
      <td>&nbsp;
		<input type="text" name="latitude" id="latitude" value="<?php echo $rowSource['psp_lat']; ?>" onBlur="float1(this,20,32);"  />
		</td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Longitude</b></td>
      <td>&nbsp;
		<input type="text" name="longitude" id="longitude" value="<?php echo $rowSource['psp_long']; ?>" onBlur="float1(this,67,80);" />
		</td>
      </tr>
	  <tr>
	  <td>&nbsp;<b>Attached with (GLR)</b></td>
	 <td>&nbsp;<input type="radio" name="att_glr" id="att_glr" value="YES" <?php if($rowSource['attached_glr']=="YES") echo "checked=\"checked\" "; ?> />Yes&nbsp;<input type="radio" name="att_glr" id="att_glr" value="NO" <?php if($rowSource['attached_glr']=="NO") echo "checked=\"checked\" "; ?>  />No</td>
	  </tr>
	    <tr>
	  <td>&nbsp;<b>Attached with CWT (Cattle water trough)</b></td>
	 <td>&nbsp;<input type="radio" name="att_cwt" id="att_cwt" value="YES"  <?php if($rowSource['attached_cwt']=="YES") echo "checked=\"checked\" "; ?>   />Yes&nbsp;<input type="radio" name="att_cwt" id="att_cwt" value="NO"  <?php if($rowSource['attached_cwt']=="NO") echo "checked=\"checked\" "; ?>   />No</td>
	  </tr>
    <tr>
	  <td>&nbsp;<b>In SC/ST Basti</b></td>
	 <td>&nbsp;<input type="radio" name="scst" id="scst" value="YES"  <?php if($rowSource['sc_st']=="YES") echo "checked=\"checked\" "; ?> />Yes&nbsp;<input type="radio" name="scst" id="scst" value="NO"  <?php if($rowSource['sc_st']=="NO") echo "checked=\"checked\" "; ?> />No</td>
	  </tr>

	  
	  <tr>
	    <td colspan="2" align="center"><input type="submit"  value="EDIT PSP" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:140px; height:30px" onClick="view_validate()"></td>
  </tr>
  </table>

    </form>
  </div>
  
 